﻿@model RBS.Core.Model.Hotel.H_Hotel_Cookbook
@{
    ViewBag.Title = "内容页";
    Layout = "~/Views/Shared/_Layout.cshtml"; 
}

<script type="text/javascript">

    $(function () {
        $('#inputCaiXi').combotree({
            url: '/Cookbook/GetCaiXiTree',
            method: 'post',
            cascadeCheck: false,
            //multiple: true,
            //required: false,
            //选择树节点触发事件  
            onSelect: function (node) {
                //返回树对象  
                var tree = $(this).tree;
                //$('#inputCaiXi').combotree('setValue', node.id);
                //选中的节点是否为叶子节点,如果不是叶子节点,清除选中  
                //var isLeaf = tree('isLeaf', node.target);
                //if (isLeaf) {
                //清除选中  
                //    $('#inputCaiXi').combotree('clear');
                //}
                $("#Cuisine").val(node.id);
            },
            onChange: function (newValue, oldValue) {
                //if (oldValue.length == 0) $('#inputCaiXi').combotree('setValue', newValue[0]);
                //else if (newValue.length == 0) $('#inputCaiXi').combotree('setValue', '');
                //else {
                //    for (var i = 0; i < newValue.length; i++) {
                //        var flag = false;
                //        for (var j = 0; j < oldValue.length; j++) {
                //            if (newValue[i] == oldValue[j]) {
                //                flag = true;
                //                break;
                //            }
                //        }
                //        if (!flag) {
                //            $('#inputCaiXi').combotree('setValue', newValue[i]);
                //            break;
                //        }
                //    }
                //}
            }
        });
        //设置菜系
        $('#inputCaiXi').combotree('setValue', "@Model.Cuisine");
        $("#submitImg").click(function () {
            if ($("#dishImg").val().length > 0) {
                ajaxFileUpload();
            } else {
                alert("请选择要上传的文件！");
            }

        });

        $("#Price").blur(function () {
            $("#Discount").val(this.value);
        });

        $("#DiscountSelect").change(function () {
            //alert(this.value);

            $("#Discount").val((this.value * $("#Price").val()).toFixed(1));
        });

    });

    function ajaxFileUpload() {
        $.ajaxFileUpload(
            {
                url: '@Url.Action("UploadImg")', //用于文件上传的服务器端请求地址
                secureuri: false, //一般设置为false
                fileElementId: 'dishImg', //文件上传空间的id属性  <input type="file" id="file" name="file" />
                dataType: 'HTML', //返回值类型 一般设置为json
                success: function (data, status)  //服务器成功响应处理函数
                {
                    $("#img1").attr("src", "../../" + data);
                    $("#showimg").attr("href", "../../" + data);
                    //$("#Hotels_License").val(data);
                    $("#DishImages").val(data);
                    if (typeof (data.error) != 'undefined') {
                        if (data.error != '') {
                            alert(data.error);
                        } else {
                            alert(data.msg);
                        }
                    }
                },
                error: function (data, status, e)//服务器响应失败处理函数
                {
                    alert(e);
                }
            }
        );
    }
    $(document).ready(function () {
        $(".upload-img").each(function () {
            $(this).InitSWFUpload({ sendurl: "@Url.Action("UploadImg")", flashurl: "@Url.Content("~/scripts/swfupload/swfupload.swf")" });
        });
    });

</script>

<!--导航栏-->
@{
    @Html.Partial("_Location");
}
<!--/导航栏-->
<!--内容-->
<div class="content-tab-wrap">
    <div id="floatHead" class="content-tab">
        <div class="content-tab-ul-wrap">
            <ul>
                <li><a href="javascript:;" onclick="tabs(this);" class="selected">基本信息</a></li>

            </ul>
        </div>
    </div>
</div>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true) 
    @Html.HiddenFor(model => model.Id)
    <div class="tab-content">
        <dl>
            <dt>菜谱分类</dt>
            <dd>
                <div class="rule-single-select">
                    @Html.DropDownListFor(model => model.CategoryId, (SelectList)ViewBag.Category, "请选择菜谱分类..", htmlAttributes: new { datatype = "*", errormsg = "请选择菜谱分类！", sucmsg = " " })
                </div>
                @Html.ActionLink("添加分类", "CookbookCategoryEdit")
            </dd>
        </dl>
        <dl>
            <dt>名称</dt>
            <dd>
                @Html.TextBoxFor(model => model.Name, null, new { @class = "input normal", datatype = "*1-10", errormsg = "填写名称！", sucmsg = " " })
                <span class="Validform_checktip">*名称</span>
            </dd>
        </dl>
        <dl>
            <dt>单价</dt>
            <dd>
                @Html.TextBoxFor(model => model.Price, null, new { @class = "input small", datatype = @"/^-?(([0-9]\d*)(\.\d{1,2})?)$|(0\.0?([1-9]\d?))$  /", errormsg = "填写单价！", sucmsg = " " })元
                   <div class="rule-single-select">
                       @Html.DropDownListFor(model => model.Unit, (SelectList)ViewBag.CBUnits, "单位", htmlAttributes: new { datatype = "*", errormsg = "请选择单位！", sucmsg = " " })
                   </div>
                <span class="Validform_checktip">*时价商品价格设置为0，结算时由服务员进行价格和斤数的填写</span>
            </dd>
        </dl>
        <dl>
            <dt>特价标识</dt>
            <dd>
                <div class="rule-multi-radio">
                    <label for="Special">否</label>
                    @Html.RadioButtonFor(model => model.Special, 0, new { @id = "radio1", @name = "Special", @checked = "checked" })
                    <label for="Special">是</label>
                    @Html.RadioButtonFor(model => model.Special, 1, new { @id = "radio1", @name = "Special" })
                    <span class="Validform_checktip">*特价标识</span>
                </div>
            </dd>
        </dl>
        <dl>
            <dt>折扣价</dt>
            <dd>
                @Html.TextBoxFor(model => model.Discount, null, new { @class = "input small" })
                <div class="rule-single-select">
                    @{
    List<SelectListItem> list = new List<SelectListItem> { 
                    new SelectListItem { Text = "请选择折扣", Value = "1"},
                    new SelectListItem { Text = "98折", Value = "0.98"},
                    new SelectListItem { Text = "95折", Value = "0.95" },
                    new SelectListItem { Text = "9折", Value = "0.90" },
                    new SelectListItem { Text = "88折", Value = "0.88" },
                    new SelectListItem { Text = "85折", Value = "0.85" },
                    new SelectListItem { Text = "8折", Value = "0.80" },
                    new SelectListItem { Text = "75折", Value = "0.75" }
                    };
                    }
                    @Html.DropDownList("DiscountSelect", list)
                </div>
            </dd>
        </dl>

        @*<dl>
            <dt>菜系</dt>
            <dd>
                <input id="inputCaiXi" class="input normal" />
                @Html.HiddenFor(model => model.Cuisine)  
            </dd>
        </dl>*@
        <dl>
            <dt>规格</dt>
            <dd>
                @Html.TextBoxFor(model => model.Component, null, new { @class = "input normal" })
                <span class="Validform_checktip">*规格</span>

            </dd>
        </dl>
        <dl>
            <dt>菜品图片</dt>
            <dd>
                @Html.TextBoxFor(model => model.DishImages, null, new { @class = "input normal upload-path" })
                @*  <img id="ImgPresss" width="169" height="44" class="upload-img1" alt=""/>*@
                <div class="upload-box upload-img"></div>
            </dd>
        </dl>

        <dl>
            <dt>烹调权重</dt>
            <dd>
                @Html.TextBoxFor(model => model.CookingWeights, null, new { @class = "input small", datatype = "n1-100", })
                <span class="Validform_checktip">*请输入1-100的数字，数值越高权重越高</span>
            </dd>
        </dl>
        @*<dl>
            <dt>点菜权限</dt>
            <dd> 
                @Html.TextBoxFor(model => model.Permissions, null, new { @class = "input normal" })
                <span class="Validform_checktip">*点菜权限</span>

            </dd>
        </dl>*@
        @* <dl>
            <dt>擅长厨师</dt>
            <dd>

                @Html.TextBoxFor(model => model.GoodCook, null, new { @class = "input normal" })
                <span class="Validform_checktip">*擅长厨师</span>

            </dd>
        </dl>*@
        @**@
        <dl>
            <dt>估清标识</dt>
            <dd>
                  @Html.TextBoxFor(model => model.EstimateClear, null, new { @class = "input small" })
                @*<div class="rule-multi-radio">
                    <label for="EstimateClear">否</label>
                    @Html.RadioButtonFor(model => model.EstimateClear, 0, new { @id = "radio1", @name = "rdolstState", @checked = "checked" })
                    <label for="EstimateClear">是</label>
                    @Html.RadioButtonFor(model => model.EstimateClear, 1, new { @id = "radio1", @name = "rdolstState" })
                </div>*@
                <span class="Validform_checktip">*-1为不设置，</span>

            </dd>
        </dl>
        <dl>
            <dt>合并烹调数量</dt>
            <dd>
                @Html.TextBoxFor(model => model.CookingNumber, null, new { @class = "input small" })
                <span class="Validform_checktip">*合并烹调数量 </span>

            </dd>
        </dl>
        <dl>
            <dt>参与配菜</dt>
            <dd> 
                <div class="rule-multi-radio">
                    <label for="StartIdentification">是</label>
                    @Html.RadioButtonFor(model => model.StartIdentification, 1, new { @id = "radio1", @name = "rdolstState" })
                    <label for="StartIdentification">否</label>
                    @Html.RadioButtonFor(model => model.StartIdentification, 0, new { @id = "radio1", @name = "rdolstState" }) 
                </div>
                <span class="Validform_checktip">(酒水等不参与配菜)</span>
            </dd>
        </dl>


    </div>
    <!--/内容-->

    <!--工具栏-->
    <div class="page-footer">
        <div class="btn-list"> 
            @{
                if (null != ViewBag.BeforeAndAfter)
                {
                    var prev = ViewBag.BeforeAndAfter["PrevId"].ToString();
                    var next = ViewBag.BeforeAndAfter["NextId"].ToString(); 
                    if (!string.IsNullOrEmpty(prev))
                    {
                       @Html.ActionLink("上一条","CookbookEdit",new{id=prev},new{ @class="btn yellow"})
                    }
                    if (!string.IsNullOrEmpty(next))
                    { 
                        @Html.ActionLink("下一条","CookbookEdit",new{id=next},new{ @class="btn yellow"})
                    }
                } 
            } 
         
            <input type="submit" value="提交保存" class="btn" />
            <input name="btnReturn" type="button" value="返回菜谱列表" class="btn yellow" onclick="javascript: history.back(-1);" />

        </div>
        <div class="clear"></div>
    </div>
    <!--/工具栏-->
        
}



